home *** CD-ROM | disk | FTP | other *** search
/ OpenGL Superbible (2nd Edition) / OpenGL SuperBible e2.iso / tools / FLTK-1.0.6 / src / Fl_Window_hotspot.cxx < prev    next >
Encoding:
C/C++ Source or Header  |  1999-01-07  |  2.4 KB  |  82 lines

  1. //
  2. // "$Id: Fl_Window_hotspot.cxx,v 1.7 1999/01/07 19:17:29 mike Exp $"
  3. //
  4. // Common hotspot routines for the Fast Light Tool Kit (FLTK).
  5. //
  6. // Copyright 1998-1999 by Bill Spitzak and others.
  7. //
  8. // This library is free software; you can redistribute it and/or
  9. // modify it under the terms of the GNU Library General Public
  10. // License as published by the Free Software Foundation; either
  11. // version 2 of the License, or (at your option) any later version.
  12. //
  13. // This library is distributed in the hope that it will be useful,
  14. // but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  16. // Library General Public License for more details.
  17. //
  18. // You should have received a copy of the GNU Library General Public
  19. // License along with this library; if not, write to the Free Software
  20. // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
  21. // USA.
  22. //
  23. // Please report all bugs and problems to "fltk-bugs@easysw.com".
  24. //
  25.  
  26. #include <FL/Fl.H>
  27. #include <FL/Fl_Window.H>
  28.  
  29. #ifdef WIN32
  30. #include <FL/win32.H>
  31. #endif
  32.  
  33. void Fl_Window::hotspot(int X, int Y, int /*offscreen*/) {
  34.   int mx,my; Fl::get_mouse(mx,my);
  35.   X = mx-X; Y = my-Y;
  36. #if 0
  37.   // Both the WIN32 and X versions do this to all windows all the time...
  38.   if (!offscreen) {
  39. #ifdef WIN32
  40.     //These will be used by reference, so we must passed different variables
  41.     int bt,bx,by;
  42.     x(X);y(Y);
  43.     Fl_X::fake_X_wm(this, X, Y, bt, bx, by);
  44.     //force FL_FORCE_POSITION to be set in Fl_Window::resize()
  45.     if (X==x()) x(X-1);
  46. #else
  47.     if (border()) {
  48.       // ensure border is on screen:
  49.       const int top = 20;
  50.       const int left = 1;
  51.       const int right = 1;
  52.       const int bottom = 1;
  53.       if (X+w()+right > Fl::w()) X = Fl::w()-right-w();
  54.       if (X-left < 0) X = left;
  55.       if (Y+h()+bottom > Fl::h()) Y = Fl::h()-bottom-h();
  56.       if (Y-top < 0) Y = top;
  57.     }
  58.     // now insure contents are on-screen (more important than border):
  59.     if (X+w() > Fl::w()) X = Fl::w()-w();
  60.     if (X < 0) X = 0;
  61.     if (Y+h() > Fl::h()) Y = Fl::h()-h();
  62.     if (Y < 0) Y = 0;
  63. #endif
  64.   }
  65. #endif
  66.   position(X,Y);
  67. }
  68.  
  69. void Fl_Window::hotspot(const Fl_Widget *o, int offscreen) {
  70.   int X = o->w()/2;
  71.   int Y = o->h()/2;
  72.   while (o != this) {
  73.     X += o->x(); Y += o->y();
  74.     o = o->window();
  75.   }
  76.   hotspot(X,Y,offscreen);
  77. }
  78.  
  79. //
  80. // End of "$Id: Fl_Window_hotspot.cxx,v 1.7 1999/01/07 19:17:29 mike Exp $".
  81. //
  82.